// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: Gunnar Ritter
//
// Per-provider settings.

#ifndef POPDIAG_UTIL_PROVIDER_H_
#define POPDIAG_UTIL_PROVIDER_H_

#include <QtCore/QString>

#include "util/common.h"

namespace popdiag {

class Provider {
 public:
  virtual ~Provider() {}

  virtual QString Name() = 0;

  virtual bool PredefinedServers() { return false; }
  virtual bool NeedEmailAddress() { return false; }
  virtual QString AccountValidationExpression() { return ".*"; }
  virtual QString SampleEmailAddress() { return "username"; }

  virtual QString ImapServer() { return ""; }
  virtual bool IsOurImapServer(const QString &/*hostname*/) { return true; }
  virtual bool ImapMustNotUseSpa() { return true; }
  virtual bool ImapVerifyUsernameFromEmailAddress(const QString &/*username*/,
                                                  const QString &/*email*/) {
    return true;
  }

  virtual QString PopServer() { return ""; }
  virtual bool IsOurPopServer(const QString &/*hostname*/) { return true; }
  virtual bool PopMustNotLeaveOnServer() { return false; }
  virtual bool PopMustNotUseSpa() { return true; }
  virtual bool PopVerifyUsernameFromEmailAddress(const QString &/*username*/,
                                                 const QString &/*email*/) {
    return true;
  }

  virtual QString SmtpServer() { return ""; }
  virtual int SmtpPort() { return SMTP_MSA_SSL_PORT; }
  virtual bool IsOurSmtpServer(const QString &/*hostname*/) { return true; }
  virtual bool SmtpVerifyUsernameFromEmailAddress(const QString &/*username*/,
                                                  const QString &/*email*/) {
    return true;
  }
  virtual bool SmtpMustNotUseSpa() { return true; }
  virtual bool SmtpMustNotUsePopBeforeSmtp() { return true; }
  virtual bool SmtpCanUsePlaintextPort() { return true; }

  virtual bool HasSupportLinks() { return false; }
  virtual QString GetSupportLink(int /*fault_code*/) { return ""; }
  virtual QString GetConfigFaultLink(int /*fault_code*/,
                                     QString /*client_id*/) {
    return "";
  }
  virtual QString GetProbeLink(QString /*probe_name*/, int /*fault_code*/) {
    return "";
  }
};

extern Provider *InitProvider();
extern Provider *provider;

}  // namespace popdiag

#endif  // POPDIAG_UTIL_PROVIDER_H_
